//有效磷  第七
$.ajax({
    type: "post",
    async: true, //异步执行
    url: "nydsj/yxl.html",
    dataType: "json", //返回数据形式为json
    success: function (json) {
        var myChart = echarts.init(document.getElementById('main7'));
        option = {
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            series: []
        };

        $.each(json, function (index, item) {
            var newArray = {};
            var itemStyle = {};
            var emphasis = {};
            emphasis.shadowBlur = 10;
            emphasis.shadowOffsetX = 0;
            emphasis.shadowColor = 'rgba(0, 0, 0, 0.5)';
            itemStyle.emphasis = emphasis;
            newArray.name = '数据';
            newArray.type = 'pie';
            newArray.radius = ['60%', '40%'];
            newArray.center = ['50%', '40%'];
            newArray.data = [];
            newArray.itemStyle = itemStyle;
            option.series.push(newArray);
        });
        $.each(json, function (index, item) {
            var dataa = {};
            for (var i = 0; i < option.series.length; i++) {
                var color = '#' + Math.floor(Math.random() * 16777216).toString(16);
                var itemStyle = {};
                itemStyle.color = color;
                dataa.value = item.phosphorus;
                dataa.name = item.region;
                dataa.itemStyle = itemStyle;
                option.series[i].data.push(dataa);
            }

        });
        myChart.setOption(option);
    },
    error: function (errorMsg) {
        alert("请求数据失败");
    }
});